SpringBoot官方文档翻译(六):创建POM文件

11.1 Creating the POM(创建POM文件)

1
2
3
We need to start by creating a Maven pom.xml file. The pom.xml is     
the recipe that is used to build your project. Open your favorite
text editor and add the following:

我们需要以创建一个pom.xml文件开始。pom.xml是用于构建项目的配方。 打开您最喜欢的文本编辑器并添加以下内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.example</groupId>
<artifactId>myproject</artifactId>
<version>0.0.1-SNAPSHOT</version>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.BUILD-SNAPSHOT</version>
</parent>

<!-- Additional lines to be added here... -->

<!-- (you don't need this if you are using a .RELEASE version) -->
<repositories>
<repository>
<id>spring-snapshots</id>
<url>https://repo.spring.io/snapshot</url>
<snapshots><enabled>true</enabled></snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<url>https://repo.spring.io/milestone</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<url>https://repo.spring.io/snapshot</url>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<url>https://repo.spring.io/milestone</url>
</pluginRepository>
</pluginRepositories>
</project>
1
2
3
The preceding listing should give you a working build. You can     
test it by running mvn package (for now, you can ignore the “jar
will be empty - no content was marked for inclusion!” warning).

上面的列表应该已经给了您一个可工作的构建。您可以使用mvn package来运行测试它(现在,你可以忽略“jar will be empty - no content was marked for inclusion!“的警告)

1
2
3
At this point, you could import the project into an IDE (most     
modern Java IDEs include built-in support for Maven). For simplicity,
we continue to use a plain text editor for this example.

在此刻,您可以导入该工程到IDE(所有的流行的javaIDE都支持导入Maven项目)。为了简化,我们继续使用纯文本编辑器编辑示例。

分享到